package edu.ccut.titan.tag.report.exporter;

import java.io.IOException;
import java.io.ObjectOutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.ccut.titan.tag.report.servlet.IReportExporter;


import net.sf.jasperreports.engine.JasperPrint;


public class ObjectReportExporter implements IReportExporter{

	public void export(JasperPrint print, HttpServletRequest request,
			HttpServletResponse response) {
		
		if (print != null) {
			ObjectOutputStream out = null;

			try {
				response.setContentType("application/octet-stream;charset=utf-8");
				out = new ObjectOutputStream(response.getOutputStream());

				out.writeObject(print);
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				if (out != null) {
					try {
						out.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		}
		
	}
}
